//
//  JWTDateString.m
//  JWT
//
//  Created by ndm on 17/2/12.
//  Copyright © 2017年 com.jwtsoft. All rights reserved.
//

#import "JWTDateString.h"

@implementation JWTDateString

SHARED_INSTANCE_IMPLEMENTATION(JWTDateString);
/** 比较2016-03-23 11:22:33格式的日期大小 */
- (BOOL)compareSmallerTwoDate:(NSString *)date1 Other:(NSString *)date2 {
    // 2016-05-26 15:09:54
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat: @"yyyy-MM-dd HH:mm:ss"];
    
    NSDate *date01 = [dateFormatter dateFromString:date1];
    NSDate *date02 = [dateFormatter dateFromString:date2];
    
    if ([date01 earlierDate:date02] == date01) { // date01 < date02
        return YES;
    }
    
    return NO;
}

/**
 日期转时间
 */
-(NSString *) stringFromDate:(NSDate *)date{
    
    NSLog(@"%@",date);//2015-11-20 00:37:40 +0000
    
    NSDateFormatter *dateFormatter=[[NSDateFormatter alloc]init];//创建一个日期格式化器
    
    dateFormatter.dateFormat=@"yyyy-MM-dd hh:mm:ss";//指定转date得日期格式化形式
    
    return [dateFormatter stringFromDate:date];
}


@end
